# -*- coding: utf-8 -*-
# @Time : 2024/4/30 11:26
# @Author : Zxg
# @Email : 1473858993@qq.com
# @File : loginscriptpage.py
# @Project : Luckin_Finance_UI
from selenium.webdriver.common.by import By
from time import sleep
from common.basepage import BasePage
from selenium.webdriver.common.action_chains import ActionChains
from common.webdriver import driver


class LoginScript(BasePage):
    # computer悬停
    hover_ele = By.XPATH, '//*[@id="Lucky-Union-Auth"]/section/div[2]/div/div[1]'
    # 定位电脑元素
    login_computer = By.XPATH, '//*[@id="Lucky-Union-Auth"]/section/div[2]/div/div[1]/div'
    # 定位用户名
    username = By.XPATH, '//*[@id="Lucky-Union-Auth"]/section/div[2]/div/div[2]/div[1]/form/div[1]/div/div/div/input'

    # 定位密码
    password = By.XPATH, '//*[@id="Lucky-Union-Auth"]/section/div[2]/div/div[2]/div[1]/form/div[2]/div/div/div/input'
    # 定位验证码
    code = By.XPATH, '//*[@id="Lucky-Union-Auth"]/section/div[2]/div/div[2]/div[1]/form/div[3]/div/div/div[1]/div/input'
    # 定位登录按钮
    login_button = By.XPATH, '//*[@id="Lucky-Union-Auth"]/section/div[2]/div/div[2]/div[1]/form/button'

    def login(self):
        # 对computer进行悬停
        self.hover(self.hover_ele)
        # 点击电脑图标
        self.click(self.login_computer)
        # 输入用户名
        self.send_key(self.username, '2017090106')
        # 输入密码
        self.send_key(self.password, 'Zc123456')
        # 输入验证码
        self.send_key(self.code, '1')
        # 点击登录按钮
        self.click(self.login_button)
